package com.xal.service.Impl;

import com.xal.mapper.StudentMapper;
import com.xal.pojo.Student;
import com.xal.service.StudentService;
import com.xal.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: MybatisSpriingBoot
 * @author: 邢奥林
 * @create: 2023-04-10 18:59
 **/
@Service
public class StudentServiceImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Result findById(Integer sid) {
        Student byId = studentMapper.findById(sid);
        return new Result(200,"查询成功",byId);
    }

    @Override
    public Result findAll() {
        List<Student> all = studentMapper.findAll();
        return new Result(200,"查询成功",all);
    }

    @Override
    public Result insert(Student student) {
        int insert = studentMapper.insert(student);
        return new Result(200,"添加成功",insert);
    }

    @Override
    public Result update(Student student) {
        int update = studentMapper.update(student);
        return new Result(200,"修改成功",update);
    }

    @Override
    public Result delete(Integer sid) {
        int delete = studentMapper.delete(sid);
        return new Result(200,"删除成功",delete);
    }
}
